package com.lry.basic.juc;

/**
 * @author:刘仁有
 * @desc:
 * @email:953506233@qq.com
 * @data:2019/7/8
 */
public class TestThread {
    boolean flag=true;
    public static void main(String[] args) throws InterruptedException {
        TestThread t = new TestThread();
        t.start();//开子线程 1
        Thread.sleep(1000);
        t.flag = false;//主线程继续跑 2
    }

    private void start() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                while(flag){
                    //加了打印就可以停，因为println会刷回主存
                    //System.out.println(1);
                }
            }
        }).start();
    }


}
